package com.bear.fastrepair.mvvm.data.manager

import com.bear.fastrepair.entity.OrderInfoPage2
import com.bear.fastrepair.entity.ResponseInfo
import com.bear.fastrepair.mvvm.data.Result
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class ManagerRepository(private val dataSource: ManagerDataSource) {

    suspend fun addManagerUser(
        account: String,
        avatar: String,
        password: String,
        regionCode: String,
        regionText: String = "",
        roleCode: String,
        tel: String,
        userName: String,
        token: String = ""
    ): Result<ResponseInfo> {
        return withContext(Dispatchers.IO) {
            val result = dataSource.addManagerUser(
                account,
                avatar,
                password,
                regionCode,
                regionText,
                roleCode,
                tel,
                userName,
                token
            )
            when (result) {
                is Result.Success -> {
                }
                is Result.Error -> {
                }
            }
            result
        }
    }

    suspend fun getOrderInfoPage(
        current: Int,
        size: Int,
        clientName: String? = null,
        clientTel: String? = null,
        employeeId: String? = null,
        orderNum: String? = null,
        orderStatus: Int? = null,
        orderTotalityStatus: Int? = null,
        regionCode: String? = null,
        token: String? = null
    ): Result<OrderInfoPage2> {
        return withContext(Dispatchers.IO) {
            val result = dataSource.getOrderInfoPage(
                current,
                size,
                clientName,
                clientTel,
                employeeId,
                orderNum,
                orderStatus,
                orderTotalityStatus,
                regionCode,
                token
            )
            result
        }
    }
}